package config

import (
	"server/share/protoc"

	"github.com/hwcer/yyds"
)

const (
	BattlePassLevelProcessName = "BattlePassLevel"
)

// 道具类型分析
func init() {
	yyds.Config.Register(&battlePass{})
}

func GetBattlePassLevel(mod, id int32) *protoc.BattlePassReward {
	i := yyds.Config.Process.Get(BattlePassLevelProcessName)
	if i == nil {
		return nil
	}
	g, ok := i.(map[uint64]*protoc.BattlePassReward)
	if !ok {
		return nil
	}
	k := uint64(mod)<<32 + uint64(id)
	return g[k]
}

type battlePass struct {
	HandleDefault
}

func (this *battlePass) Handle(c *yyds.CS, i any) {
	data := i.(*output)

	bpw := map[uint64]*protoc.BattlePassReward{}
	for _, v := range data.BattlePassReward {
		rk := uint64(v.Group)<<32 + uint64(v.Lv)
		bpw[rk] = v
	}
	c.Process.Set(BattlePassLevelProcessName, bpw)

	return
}
